package com.example.backend.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.backend.entity.Like;
import com.example.backend.entity.PostVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author Jcy
 * @Date 2022/5/4
 */
@Mapper
public interface LikeMapper extends BaseMapper<Like> {
    /**
     * @param postId
     * @param userId
     * @return
     */
    @Select("SELECT tb_like.like_id,tb_like.like_user_id,tb_like.like_post_id,tb_like.create_date FROM tb_like WHERE tb_like.like_user_id=#{userId} AND tb_like.like_post_id=#{postId}")
    List<PostVO> getLike(@Param("postId") int postId, @Param("userId") int userId,Page<PostVO> page);

    @Select("SELECT *  FROM tb_like WHERE tb_like.like_user_id=#{userId} AND tb_like.like_post_id=#{postId}")
    Like getLikeCount(@Param("postId") int postId,@Param("userId") int userId);

    @Select("SELECT tb_like.like_id FROM tb_like WHERE tb_like.like_post_id =#{postId}")
    List<Integer> getLikeId(@Param("postId") int postId);
}
